unsigned long last = millis();


void IrRemote() {
  // Process the IR input, if any

  if (irrecv.decode(&results)) {
    if (results.value == Red_CODE || results.value == Red_CODE1) {
        if (millis() - last > 250) {
          rcount++; 
          count();
    }
    } 
    else if (results.value == Green_CODE || results.value == Green_CODE1) {
      Serial.write("Green\n");
          }  
    else if (results.value == Blue_CODE || results.value == Blue_CODE1) {
      Serial.write("Blue\n");
          } 
    else if (results.value == Yellow_CODE || results.value == Yellow_CODE1) {
    Serial.write("Yellow 20\n");
    }
    else if (results.value == TeleText_CODE || results.value == TeleText_CODE1) {
    Serial.write("TeleText 20\n");
    }
    else {
      Serial.print("unexpected value: ");
      Serial.println(results.value, HEX);
    }
    last = millis();
    irrecv.resume(); // Resume decoding (necessary!)
  }
}

void count() {
    if (rcount==1)
  {
    Serial.write("Red1\n");
  }
    if (rcount==2)
  {
    Serial.write("Red2\n");
  }
    if (rcount==3)
  {
    Serial.write("Red3\n");
  }
    if (rcount==4)
  {
    Serial.write("Red4\n");
    RandomColours();
  }
    if (rcount==5)
  {
    Serial.write("Red5\n");
  }
    if (rcount==6)
  {
    Serial.write("Red6\n");
    rcount=0;
  }
}
  
